#ifndef _BIO_CPP_PARSEHMM_H
#define _BIO_CPP_PARSEHMM_H
#include <iostream>
#include <string>
/*
	Example:

	struct TProcess_HMM_record
	{
		bool operator()(const std::vector<string>& vec_lines, unsigned seqcnt);
		void report_error(const std::vector<string>& vec_lines, unsigned seqcnt);
	};

	bool TProcess_HMM_record::operator()(const std::vector<string>& vec_lines, unsigned seqcnt)
	{
		return true;
	}

	void FooBar_blah_de_blah()
	{
		TSequenceData seq_data;
		Process_HMM_Records(cin, hmm_data);
	}

*/
namespace BioCPP
{
//******************************************************************************

//	Process_FA_Sequences

//		reads each sequence and calculates running totals for statistics
//
//******************************************************************************
template <class Ty_>
void Process_HMM_Records(std::istream& istrm, Ty_& process_record)
{
	// These two variables will be non empty AFTER the first sequence is read
	std::vector<std::string> vec_lines;
	unsigned line_cnt = 0U;
	

	// get each line in the HMM file
	std::string line;
	while (std::getline(istrm, line))
	{
		++line_cnt;

		// process on end of record
		if (line[0] == '/' && line[1] == '/' )
		{
			if (vec_lines.size() && !process_record(vec_lines, line_cnt))
				return;

			vec_lines.clear();
			continue;
		}
			
		vec_lines.push_back(line);
	}


	// if a previous record has been read in successfully, process that			
	if (vec_lines.size())
		process_record.report_error(vec_lines, line_cnt);
}


}
#endif //_BIO_CPP_PARSEHMM_H
